const mongoose = require("mongoose");
mongoose.pluralize(null); //去掉集合后面的s
const { Schema, model } = mongoose;
const versionKey = { versionKey: false };
const moment = require("moment");
moment.locale("zh-cn");
// 评论表
const CommentSchema = new Schema({
  user_uid: String, //评论用户uid
  author_uid: String, //作者uid
  user_id: {
    //关联用户表
    type: mongoose.Types.ObjectId,
    ref: "user",
    required: true,
  },
  article_id: {
    //关联游记表
    type: mongoose.Types.ObjectId,
    ref: "usertravel",
    required: true,
  },
  time: {
    type: String,
    default: () => moment().utcOffset(8).format("YYYY-MM-DD"),
  },
  content: {
    //评论内容
    type: String,
    trim: true,
  },
},versionKey);

module.exports = {
  modelComment: model("comment", CommentSchema),
};
